import { CylinderCollider, find, Label, Sprite, SpriteFrame, Vec2, view } from 'cc';
import { tween } from 'cc';
import { UITransform } from 'cc';
import { Tween } from 'cc';
import { ColliderComponent } from 'cc';
import { ITriggerEvent } from 'cc';
import { Texture2D } from 'cc';
import { Vec3 } from 'cc';
import { MeshRenderer } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { App } from '../../../App';
import UtilTool from '../../../tools/UtilTool';
import { Ball } from '../Ball';
import { GamePlayState } from '../GameBaseLogic';
import { GameBloodLogic } from './GameBloodLogic';
import { GameLayer5 } from './GameLayer5';
import { GameModel5 } from './GameModel5';
const { ccclass, property } = _decorator;

// 球洞分数区域
@ccclass('GameBloodRoleScore')
export class GameBloodRoleScore extends Component {
    @property(Node)
    spr1 : Node = null

    @property(Node)
    spr2 : Node = null

    @property(Node)
    spr3 : Node = null

    @property(Label)
    scoreLabel : Label = null

    // 区域所属分数
    score = 0  
    
    // 区域等级
    level = 1 // 0~5范围

    start() {
        let tweenScale = tween(this.spr2)
            .to(0.4, {scale: new Vec3(0.8, 1, 0.8)})
            .to(0.4, {scale: new Vec3(1, 1, 1)})
        tween(this.spr2).repeatForever(tweenScale).start()

        tween(this.spr3)
            .by(1.0, { angle: -360 })
            .repeatForever()
            .start()

    }

    /**
     * 初始化区域属性
     */
    init(level) {
       this.level = level
    }

    /**刷新界面 */
    updateView(holeScoreMap) {
        this.node.active = true
        let v = holeScoreMap[this.level.toString()]
        if (v) {
            this.score = v
            this.scoreLabel.string = "+" + v
        }
    }

    onDestroy() {
        
    }

}

